﻿#region Header

/*
Remote views based on linq
By

Pascal Hauser 
Dipl. Ing. in Informatik, Hochschule für Technik Rapperswil, 2006
Master Thesis, Hochschule für Technik Rapperswil, 2008-2010

and

Raphael Gfeller
Dipl. Ing. in Informatik, Hochschule für Technik Rapperswil, 2006
Master Thesis, Hochschule für Technik Rapperswil, 2008-2010

*/

#endregion

#region Usings

using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;
using Sebarf.Diagnostics.Interfaces;

#endregion

namespace Prototyp1.TestServer {
	/// <summary>
	/// Entry point
	/// </summary>
	internal class Program {
		#region Public Methods

		private static void Main(string[] args) {
			if (args.Length == 1) {
				var server = new InterLinqServerRemotControl();
				server.Start(args[0]);
				Console.ReadLine();
			}
			else if (args.Length == 4) {
				var server = new InterLinqServerRemotControl();
				server.Start(args[0], args[1], args[2], args[3]);
				Console.ReadLine();
			}
			else {
				Logger.WriteInformation("start interLinq server");
				// register remote object
				ChannelServices.RegisterChannel(new TcpChannel(8082), false);
				RemotingConfiguration.ApplicationName = "InterLinqServer";
				RemotingConfiguration.RegisterWellKnownServiceType(typeof(InterLinqServerRemotControl), "RemoteServer",
																	WellKnownObjectMode.Singleton);
				Logger.WriteInformation("InterLinq server started, waiting on orders on tcp:8092\\InterLinqServer\\RemoteServer");
			}
			while (Console.ReadLine().Length > 0) {
			}

		#endregion
		}
	}
}